// 导入数据库操作模块
const db = require('../db/index.js')

// 获取大屏可视化列表
exports.getBigScreen = (req, res) => {
    // 定义大屏可视化的 SQL 语句
    const sql = `SELECT workerNumber,maintenanceRate,history,pipeNumber FROM  bigscreen`
     db.query(sql, (err, result1) => {
      const sql2 = `SELECT yCoordinate FROM bigscreen`
          db.query(sql2,(err,result2)=>{
            const yCoordinate = []
            result2.forEach((item,index) => {
              yCoordinate[index] = item.yCoordinate
            })
          const sql3 = `SELECT name,value FROM bigscreen`
          db.query(sql3,(err,result3)=>{
            const res3 = [result3[0],result3[1],result3[2]]
            res.send({
              code: 200,
              msg: '获取大屏可视化列表成功！',
              data: {
                baseInfo: result1[0],
                barInfo: {yCoordinate},
                pieInfo: res3
            }
          })
        })
      })
   })
}
